<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="Java、MySql、Spring、JVM、虚拟机、数据库、Docker、Redis" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>深入理解JVM（五）垃圾收集日志及实用虚拟机工具 |  ACEXS个人博客</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/blog-page/favicon.ico" />
       
<link rel="stylesheet" href="/blog-page/dist/main.css">

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css"
      />
      
<link rel="stylesheet" href="/blog-page/css/custom.css">
 
      <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/blog-page/atom.xml" title="ACEXS个人博客" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-深入理解JVM（五）垃圾收集日志及实用虚拟机工具"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  深入理解JVM（五）垃圾收集日志及实用虚拟机工具
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/blog-page/2021/10/19/788230c0de2b.html" class="article-date">
  <time datetime="2021-10-19T09:24:29.000Z" itemprop="datePublished">2021-10-19</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/blog-page/categories/%E8%AF%BB%E4%B9%A6%E6%88%90%E8%AF%97/">读书成诗</a> / <a class="article-category-link" href="/blog-page/categories/%E8%AF%BB%E4%B9%A6%E6%88%90%E8%AF%97/JVM/">JVM</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">11 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="虚拟机及GC日志"><a href="#虚拟机及GC日志" class="headerlink" title="虚拟机及GC日志"></a>虚拟机及GC日志</h1><h2 id="现状"><a href="#现状" class="headerlink" title="现状"></a>现状</h2><ul>
<li>JDK9之前HotSpot未提供统一日志处理框架，虚拟机各模块的日志开关分布在不同参数上，日志级别、循环日志大小、输出格式、重定向等设置在不同功能上都要单独解决。</li>
<li>JDK9HotSpot所有功能日志都收归到了“-Xlog”参数上。</li>
</ul>
<h3 id="Xlog"><a href="#Xlog" class="headerlink" title="-Xlog"></a>-Xlog</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-Xlog[:[selector][:[output][:[decorators][:output-options]]]]</span><br></pre></td></tr></table></figure>

<h3 id="参数解析"><a href="#参数解析" class="headerlink" title="参数解析"></a>参数解析</h3><p><strong>selector</strong></p>
<ul>
<li>Tag</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">add, age, alloc, annotation, aot, arguments, attach, barrier, biasedlocking, blocks, bot, breakpoint, bytecode, cds, census, <span class="class"><span class="keyword">class</span>, <span class="title">classhisto</span>, <span class="title">cleanup</span>, <span class="title">codecache</span>, <span class="title">compaction</span>, <span class="title">compilation</span>, <span class="title">constantpool</span>, <span class="title">constraints</span>, <span class="title">container</span>, <span class="title">coops</span>, <span class="title">cpu</span>, <span class="title">cset</span>, <span class="title">data</span>, <span class="title">datacreation</span>, <span class="title">dcmd</span>, <span class="title">decoder</span>, <span class="title">defaultmethods</span>, <span class="title">director</span>, <span class="title">dump</span>, <span class="title">dynamic</span>, <span class="title">ergo</span>, <span class="title">event</span>, <span class="title">exceptions</span>, <span class="title">exit</span>, <span class="title">fingerprint</span>, <span class="title">free</span>, <span class="title">freelist</span>, <span class="title">gc</span>, <span class="title">handshake</span>, <span class="title">hashtables</span>, <span class="title">heap</span>, <span class="title">humongous</span>, <span class="title">ihop</span>, <span class="title">iklass</span>, <span class="title">init</span>, <span class="title">inlining</span>, <span class="title">install</span>, <span class="title">interpreter</span>, <span class="title">itables</span>, <span class="title">jfr</span>, <span class="title">jit</span>, <span class="title">jni</span>, <span class="title">jvmti</span>, <span class="title">liveness</span>, <span class="title">load</span>, <span class="title">loader</span>, <span class="title">logging</span>, <span class="title">malloc</span>, <span class="title">mark</span>, <span class="title">marking</span>, <span class="title">membername</span>, <span class="title">memops</span>, <span class="title">metadata</span>, <span class="title">metaspace</span>, <span class="title">methodcomparator</span>, <span class="title">mirror</span>, <span class="title">mmu</span>, <span class="title">module</span>, <span class="title">monitorinflation</span>, <span class="title">monitormismatch</span>, <span class="title">nestmates</span>, <span class="title">nmethod</span>, <span class="title">normalize</span>, <span class="title">numa</span>, <span class="title">objecttagging</span>, <span class="title">obsolete</span>, <span class="title">oldobject</span>, <span class="title">oom</span>, <span class="title">oopmap</span>, <span class="title">oops</span>, <span class="title">oopstorage</span>, <span class="title">os</span>, <span class="title">pagesize</span>, <span class="title">parser</span>, <span class="title">patch</span>, <span class="title">path</span>, <span class="title">perf</span>, <span class="title">periodic</span>, <span class="title">phases</span>, <span class="title">plab</span>, <span class="title">preorder</span>, <span class="title">preview</span>, <span class="title">promotion</span>, <span class="title">protectiondomain</span>, <span class="title">ptrqueue</span>, <span class="title">purge</span>, <span class="title">record</span>, <span class="title">redefine</span>, <span class="title">ref</span>, <span class="title">refine</span>, <span class="title">region</span>, <span class="title">reloc</span>, <span class="title">remset</span>, <span class="title">resolve</span>, <span class="title">safepoint</span>, <span class="title">sampling</span>, <span class="title">scavenge</span>, <span class="title">setting</span>, <span class="title">smr</span>, <span class="title">stackmap</span>, <span class="title">stacktrace</span>, <span class="title">stackwalk</span>, <span class="title">start</span>, <span class="title">startuptime</span>, <span class="title">state</span>, <span class="title">stats</span>, <span class="title">streaming</span>, <span class="title">stringdedup</span>, <span class="title">stringtable</span>, <span class="title">subclass</span>, <span class="title">survivor</span>, <span class="title">sweep</span>, <span class="title">symboltable</span>, <span class="title">system</span>, <span class="title">table</span>, <span class="title">task</span>, <span class="title">thread</span>, <span class="title">time</span>, <span class="title">timer</span>, <span class="title">tlab</span>, <span class="title">tracking</span>, <span class="title">unload</span>, <span class="title">unshareable</span>, <span class="title">update</span>, <span class="title">verification</span>, <span class="title">verify</span>, <span class="title">vmmutex</span>, <span class="title">vmoperation</span>, <span class="title">vmthread</span>, <span class="title">vtables</span>, <span class="title">vtablestubs</span>, <span class="title">workgang</span></span></span><br><span class="line"><span class="class"><span class="title">Specifying</span> &quot;<span class="title">all</span>&quot; <span class="title">instead</span> <span class="title">of</span> <span class="title">a</span> <span class="title">tag</span> <span class="title">combination</span> <span class="title">matches</span> <span class="title">all</span> <span class="title">tag</span> <span class="title">combinations</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li><p>Level</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>级别</th>
</tr>
</thead>
<tbody><tr>
<td>Trace</td>
<td>最低级别日志，输出内容最详细</td>
</tr>
<tr>
<td>Debug</td>
<td>输出调试程序日志内容</td>
</tr>
<tr>
<td>Info （默认）</td>
<td>输出程序运行时正常的信息</td>
</tr>
<tr>
<td>Warning</td>
<td>警告</td>
</tr>
<tr>
<td>Error</td>
<td>错误</td>
</tr>
<tr>
<td>Off</td>
<td>最高级别日志</td>
</tr>
</tbody></table>
</li>
</ul>
<p><strong>output</strong></p>
<ul>
<li><p>stdout表示标准输出</p>
</li>
<li><p>stderr表示标准错误</p>
</li>
</ul>
<p><strong>decorators</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>time</td>
<td>当前日期和时间</td>
</tr>
<tr>
<td>uptime（默认）</td>
<td>虚拟机启动到现在经过的时间</td>
</tr>
<tr>
<td>timemillis</td>
<td>当时间的毫秒数（时间戳）</td>
</tr>
<tr>
<td>uptimemillis</td>
<td>虚拟机启动到现在经过的毫秒数</td>
</tr>
<tr>
<td>timeanos</td>
<td>当前时间的纳秒数</td>
</tr>
<tr>
<td>pid</td>
<td>进程ID</td>
</tr>
<tr>
<td>tid</td>
<td>线程ID</td>
</tr>
<tr>
<td>level（默认）</td>
<td>日志级别</td>
</tr>
<tr>
<td>tags（默认）</td>
<td>日志输出的标签集</td>
</tr>
</tbody></table>
<p><strong>output-options</strong></p>
<p>日志输出文件配置，文件数量，文件大小等。</p>
<h1 id="对象分配与回收策略"><a href="#对象分配与回收策略" class="headerlink" title="对象分配与回收策略"></a>对象分配与回收策略</h1><h2 id="对象分配原则"><a href="#对象分配原则" class="headerlink" title="对象分配原则"></a>对象分配原则</h2><ul>
<li><p>大多数情况下，对象在新生代Eden区分配。当Eden区没有足够空间进行分配时，虚拟机发起一次Minor GC。</p>
</li>
<li><p>大对象直接进入老年代</p>
</li>
<li><p>长期存活的对象进入老年代</p>
</li>
<li><p>动态对象年龄判定：HotSpot虚拟机并非要求对象年龄必须达到-XX:MaxTenuringThreshold才能晋升老年代，如果在Survivor空间中，相同年龄所有对象大小的总和大于Survivor空间的一半，年龄大于或等于该年龄的对象就可以直接进入老年代，无需等到-XX:MaxTenuringThreshold中要求的年龄</p>
</li>
<li><p>空间分配担保：在发生Minor GC之前，虚拟机必须先检查老年代最大可用连续空间是否大于新生代所有对象总空间，如果成立，那这次Minor GC可以确保是安全的。如果不成立，虚拟机先查看是否配置参数，允许分配担保失败，如果允许，继续检查老年代最大可用的连续空间是否大于历次晋升到老年代的对象平均大小，如果大于，将进行一次Minor GC,如果小于，或者不允许担保失败，这时要改为进行一次Full GC。</p>
<h1 id="虚拟机工具"><a href="#虚拟机工具" class="headerlink" title="虚拟机工具"></a>虚拟机工具</h1><h2 id="基础故障处理工具"><a href="#基础故障处理工具" class="headerlink" title="基础故障处理工具"></a>基础故障处理工具</h2><p><strong>基础工具：用于支持基本的程序创建和运行</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>是否移除</th>
</tr>
</thead>
<tbody><tr>
<td>applet viewer</td>
<td>不适用Web浏览器情况下运行和调试Applet</td>
<td>JDK11</td>
</tr>
<tr>
<td>extcheck</td>
<td>检查JAR冲突的工具</td>
<td>JDK9</td>
</tr>
<tr>
<td>jar</td>
<td>创建和管理JAR文件</td>
<td></td>
</tr>
<tr>
<td>java</td>
<td>Java运行工具，用于运行Class文件或JAR文件</td>
<td></td>
</tr>
<tr>
<td>javac</td>
<td>用于Java语言的编译器</td>
<td></td>
</tr>
<tr>
<td>javadoc</td>
<td>Java的API文档生成器</td>
<td></td>
</tr>
<tr>
<td>javah</td>
<td>C语言头文件和stub函数生成器，用于编写JNI方法</td>
<td></td>
</tr>
<tr>
<td>javap</td>
<td>Java字节码分析工具</td>
<td></td>
</tr>
<tr>
<td>jlink</td>
<td>将Module和它的依赖打包成一个运行时镜像文件</td>
<td></td>
</tr>
<tr>
<td>jdb</td>
<td>基于JPDA协议的调试器，以类似于GDB方式进行调试Java代码</td>
<td></td>
</tr>
<tr>
<td>jdeps</td>
<td>Java类依赖性分析器</td>
<td></td>
</tr>
<tr>
<td>jdeprscan</td>
<td>用于搜索JAR包中使用了’deprecated’的类，JDK9开始提供</td>
<td></td>
</tr>
</tbody></table>
<p><strong>安全：用于程序签名、设置安全测试等。</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>keytool</td>
<td>管理密钥库和证书，主要用于获取或缓存Kerberos协议的票据授权票据。允许用户查看本地凭据缓存和密钥表中的条目。</td>
<td></td>
</tr>
<tr>
<td>jarsigner</td>
<td>生成并验证JAR签名</td>
<td></td>
</tr>
<tr>
<td>policytool</td>
<td>管理策略文件的GUI工具，用于管理用户策略文件</td>
<td>JDK10</td>
</tr>
</tbody></table>
<p><strong>国际化：用于创建本地语言文件</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>native2ascii</td>
<td>本地编码到ASCII编码的转换器，用于“任意手指吃的字符编码”和与之相对应的“ASCII编码和Unicode转义”之间的相互转换。</td>
<td></td>
</tr>
</tbody></table>
<p><strong>远程方法调用：用于跨Web或网络的服务交互</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>rmic</td>
<td>Java RMI编译器，未使用JRMP或IIOP协议的远程对象生成Stub、Skeleton和Tie类，也用于生成OMG IDL。</td>
<td></td>
</tr>
<tr>
<td>rmiregistry</td>
<td>远程对象注册表服务，用于在当前主机制定端口上创建并开启一个远程对象注册表。</td>
<td></td>
</tr>
<tr>
<td>rmid</td>
<td>启动激活系统守护进程，允许在虚拟机中注册或激活对象</td>
<td></td>
</tr>
<tr>
<td>serialver</td>
<td>生成并返回指定类的序列化版本ID</td>
<td></td>
</tr>
</tbody></table>
<p><strong>Java IDL与RMI-IIOP：在JDK11中不再提供。</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>tnameserv</td>
<td>提供对命名服务的访问</td>
<td>JDK11</td>
</tr>
<tr>
<td>idlj</td>
<td>IDL转Java编译器，生成映射OMG IDL接口的Java源文件，并启用以Java编程语言编写的使用CORBA功能的应用程序的Java源文件，IDL意即接口定义语言</td>
<td>JDK11</td>
</tr>
<tr>
<td>orbd</td>
<td>对象请求代理守护进程，提供从客户端查找和调用CORBA环境服务端上的持久化对象的功能，使用ORBD代替瞬态命名服务，tnameserv。ORBD包括瞬态命名服务和持久命名服务。ORBD工具继承了服务器管理器，互操作命名服务和引导名称服务器的功能，当客户端想进行服务器定位、注册和激活功能时，可以与servertool一起使用</td>
<td>JDK11</td>
</tr>
<tr>
<td>servertool</td>
<td>为应用程序注册、注销、启动和关闭服务器提供易用的接口。</td>
<td></td>
</tr>
</tbody></table>
<p><strong>部署工具：用于程序打包、发布和部署</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>javapackager</td>
<td>打包，签名Java和JavaFX应用程序</td>
<td>JDK11</td>
</tr>
<tr>
<td>pack200</td>
<td>使用Java GZIP压缩器将JAR文件转换为压缩的Pack200文件，压缩的压缩文件是高度压缩的JAR，可以直接部署，节省带宽并减少下载时间</td>
<td></td>
</tr>
<tr>
<td>unpack200</td>
<td>将Pack200生成的打包文件解压提取为JAR文件</td>
<td></td>
</tr>
</tbody></table>
<p><strong>Java Web Start</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>javaws</td>
<td>启动Java Web Start并设置各种选项工具</td>
<td>JDK11</td>
</tr>
</tbody></table>
<p><strong>性能监控和故障处理：用于监控分析Java虚拟机运行信息，排查问题。</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>jps</td>
<td>JVM Process Status Tool，显示制定系统内所有HotSpot虚拟机进程</td>
<td></td>
</tr>
<tr>
<td>jstat</td>
<td>JVM Statistics Monitoring Tool，用于收集HotSpot虚拟机各方面运行数据</td>
<td></td>
</tr>
<tr>
<td>jstatd</td>
<td>JVM Statistics  Monitoring Tool Daemon，jstat守护进程，启动一个RMI服务器应用程序用于监视测试的HotSpot虚拟机的创建和终止，并提供一个界面，允许远程监控工具附加到在本地系统上运行的虚拟机，在JDK9中集成到了JHSDB中</td>
<td></td>
</tr>
<tr>
<td>jinfo</td>
<td>Configuration Info for Java，显示虚拟机配置信息，在JDK9中集成到了JHSDB中</td>
<td></td>
</tr>
<tr>
<td>jmap</td>
<td>Memory Map for Java，生成虚拟机内存转储快照（heapdump文件）。在JDK9中集成到了JHSDB中</td>
<td></td>
</tr>
<tr>
<td>jhat</td>
<td>JVM Heap Analysis Tool，用于分析堆转储快照，它会建立一个Http/Web服务器，让用户可以再浏览器上查看分析结果，JDK9中被JHSDB代替</td>
<td></td>
</tr>
<tr>
<td>jstack</td>
<td>Stack Trace for Java，显示虚拟机的线程快照，JDK9中集成到了JHSDB中</td>
<td></td>
</tr>
<tr>
<td>jhsdb</td>
<td>Java HotSpot Debugger，一个基于Serviceability Agent的HotSpot进程调试器，从JDK9开始提供</td>
<td></td>
</tr>
<tr>
<td>jsadebugd</td>
<td>Java Serviceability Agent Debug Daemon，适用于Java的可维护性代理测试守护程序，主要用于附加到制定的Java进程，核心文件，或充当一个调试服务器</td>
<td></td>
</tr>
<tr>
<td>jcmd</td>
<td>JVM Command，虚拟机诊断命令工具，将诊断命令请求发送到正在运行的Java虚拟机，从JDK7开始提供</td>
<td></td>
</tr>
<tr>
<td>jconsole</td>
<td>Java Console，用于监控Java虚拟机的使用JMX规范的图形工具，它可以监控本地和远程Java虚拟机，还可以监控和管理应用程序</td>
<td></td>
</tr>
<tr>
<td>jmc</td>
<td>Java Mission Control，包含用于监控和管理Java应用程序的工具，而不会引入与这些工具相关联的性能开销，开发者可以使用jmc命令创建JMC工具，从JDK7 Update 40开始集成到Open JDK中</td>
<td></td>
</tr>
<tr>
<td>jvisualvm</td>
<td>Java Visual VM，一种图形化工具，可在Java虚拟机中运行时提供有关基于Java技术的应用程序的详细信息，Java Visual VM提供内存和CPU分析、堆转储分析、内存泄漏检测、MBean访问和垃圾收集。从JDK6 Update7 开始提供，从JDK9不再打包到JDK中，但仍保持更新发展，可独立下载</td>
<td></td>
</tr>
</tbody></table>
<p><strong>WebService工具：与CORBA一起在JDK11中被移除</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>schemagen</td>
<td>用于XML绑定的Schema生成器，用于生成XML Schema文件</td>
<td>JDK11</td>
</tr>
<tr>
<td>wsgen</td>
<td>XML Web Service 2.0的Java API，生成用于JAX-WS Web Service的JAX-WS便携式产物</td>
<td>JDK11</td>
</tr>
<tr>
<td>wsimport</td>
<td>XML Web Service 2.0的Java API，主要用于根据服务端发布的WSDL文件生成客户端</td>
<td>JDK11</td>
</tr>
<tr>
<td>xjc</td>
<td>主要用于根据XML Schema 文件生成对应的Java类</td>
<td>JDK11</td>
</tr>
</tbody></table>
<p><strong>REPL和脚本工具</strong></p>
<table>
<thead>
<tr>
<th>名称</th>
<th>主要作用</th>
<th>移除</th>
</tr>
</thead>
<tbody><tr>
<td>jshell</td>
<td>基于Java的Shell REPL交互工具</td>
<td></td>
</tr>
<tr>
<td>jjs</td>
<td>堆Nashorn引擎的调用入口，Nashorn是基于Java实现的一个轻量级高性能JavaScript运行环境</td>
<td></td>
</tr>
<tr>
<td>jrunscript</td>
<td>Java命令行脚本外壳工具，主要用于解释执行JavaScript、Groovy、Ruby等脚本语言</td>
<td></td>
</tr>
</tbody></table>
</li>
</ul>
<h2 id="可视化故障处理工具"><a href="#可视化故障处理工具" class="headerlink" title="可视化故障处理工具"></a>可视化故障处理工具</h2><p><strong>1、JHSDB</strong></p>
<p><strong>实现原理：</strong>基于服务性代理实现的进程外调试工具，服务性代理以HotSpot内部数据结构为参照物进行设计，把这些C++的数据抽象出Java模型对象，相当于HotSpot的C++代码的一个镜像。通过服务性代理API，可以在一个独立的Java虚拟机的进程中分析其他HotSpot虚拟机的内部数据，或者从HotSpot虚拟机进程内存中dump出来的转储快照里还原出它的运行状态细节。服务性代理跟Linux上的GDB或者Windows上的Windbg是相似的。</p>
<p><strong>2、JConsole</strong></p>
<p>是一款基于JMX（Java Management Extensions）的可视化监控、管理工具。主要功能是通过JMX的MBean（Managed Bean）对系统进行信息收集和参数动态调整。</p>
<p><strong>3、VisualVM（OQL查询语句）</strong></p>
<p>是功能最强大的监视和故障处理程序之一，除此之外还可以进行性能分析。VisualVM的一个很大优势是：不需要被监视的程序基于特殊Agent去运行，因此通用性很强，对应用程序实际产生的影响也比较小。</p>
<p><strong>4、Java Mission Control</strong></p>
<p><strong>JFR（Java Flight Recorder）：</strong>飞行记录仪，是一套内建在HotSpot虚拟机里面的监控和基于时间的信息收集框架，与其他监控工具相比，它有可持续在线的特性，JFR在生产环境中对吞吐量的影响一般不超过1%，而JFR监控过程的开始、停止都是完全可动态的。</p>
<p><strong>JMC（Java Mission Control）：</strong>JMC与虚拟机之间采用JMX协议进行通信，JMC一方面作为JMX控制台，显示来自虚拟机MBean提供的数据，另一方面作为JFR的分析工具，展示来自JFR的数据。</p>
<h2 id="HotSpot虚拟机插件及工具"><a href="#HotSpot虚拟机插件及工具" class="headerlink" title="HotSpot虚拟机插件及工具"></a>HotSpot虚拟机插件及工具</h2><p><strong>位置：</strong>hotspot/src/share/tools</p>
<p><strong>种类：</strong></p>
<ul>
<li><strong>Ideal Graph Visualizer：</strong>可视化展示C2即时编译器是如何将字节码转化为理想图，然后转化为机器码的。</li>
<li><strong>Client Complier Visualizer：</strong>用于查看C1即时编译器生成高级中间表示（HIR），转换成低击中间表示（LIR）和做物理寄存器分配的过程。</li>
<li><strong>MakeDeps：</strong>帮助处理HotSpot的编译依赖的工具。</li>
<li><strong>Project Creator：</strong>帮忙生成Visual Studio的.project文件的工具。</li>
<li><strong>LogCompilation：</strong>将-XX:+LogCompilation输出的日志整理成更容易阅读的格式的工具。</li>
<li><strong>HSDIS：</strong>即时编译器的反汇编插件。</li>
</ul>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://acexxs.gitee.io/blog-page/2021/10/19/788230c0de2b.html" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog-page/tags/GC/" rel="tag">GC</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog-page/tags/JVM/" rel="tag">JVM</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog-page/tags/Java/" rel="tag">Java</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/blog-page/2021/10/19/0eaed7906b18.html" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            深入理解JVM（六）虚拟机调优实战
          
        </div>
      </a>
    
    
      <a href="/blog-page/2021/10/19/7e65be3fe4f8.html" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">深入理解JVM（四）垃圾收集器实现细节</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "4Gx0dzptNxW0Nb4xekYQLQF1-gzGzoHsz",
    app_key: "nvoM2TGGO7QpNlr3vAy3DQyg",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "欢迎一起探讨交流~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2021
        <i class="ri-heart-fill heart_icon"></i> ACEXS
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/blog-page/"><img src="/blog-page/images/ayer-side.svg" alt="ACEXS个人博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog-page/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog-page/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog-page/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog-page/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog-page/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog-page/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/blog-page/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>表扬一下吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/blog-page/images/alipay.png">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/blog-page/images/wechat.png">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/blog-page/js/jquery-3.6.0.min.js"></script>
 
<script src="/blog-page/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/blog-page/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/blog-page/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/blog-page/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/blog-page/css/clipboard.css">
 <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->
 
<script src="/blog-page/js/dz.js"></script>
 
<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>